######################################################################################################
# source file if the folder level of the deepest source is bigger than 5 than add some codes as below：
# FILES6 := $(foreach v,$(FILES5),$(wildcard $(v)/*))
# SOURCE6 := $(foreach v,$(FILES5),$(wildcard $(v)/*.c))
# FILES := $(FILES1) $(FILES2) $(FILES3) $(FILES4) $(FILES5) $(FILES6) 
# ...
######################################################################################################
include makefile.conf
SUBDIRS := .
FILES1 := $(foreach v,$(SUBDIRS),$(wildcard $(v)/*))
SOURCE1 := $(foreach v,$(SUBDIRS),$(wildcard $(v)/*.c))
FILES2 := $(foreach v,$(FILES1),$(wildcard $(v)/*))
SOURCE2 := $(foreach v,$(FILES1),$(wildcard $(v)/*.c))
FILES3 := $(foreach v,$(FILES2),$(wildcard $(v)/*))
SOURCE3 := $(foreach v,$(FILES2),$(wildcard $(v)/*.c))
FILES4 := $(foreach v,$(FILES3),$(wildcard $(v)/*))
SOURCE4 := $(foreach v,$(FILES3),$(wildcard $(v)/*.c))
FILES5 := $(foreach v,$(FILES4),$(wildcard $(v)/*))
SOURCE5 := $(foreach v,$(FILES4),$(wildcard $(v)/*.c))
FILES := $(FILES1) $(FILES2) $(FILES3) $(FILES4) $(FILES5) 
SOURCES := $(SOURCE1) $(SOURCE2) $(SOURCE3) $(SOURCE4) $(SOURCE5) 
# target you can change test to what you want
# 目标文件名，输入任意你想要的执行文件名
TARGET := workspace
# #compile and lib parameter
# #编译参数
CC := gcc
LIBS :=
LDFLAGS :=
DEFINES := -fmessage-length=0 $(ENABLE_TEST_CFG)

INCLUDE := -I. 
CFLAGS := -O0 -g3 -ftest-coverage -fprofile-arcs -Wall $(DEFINES) $(INCLUDE)
CXXFLAGS:= $(CFLAGS) -DHAVE_CONFIG_H -Wl,-Map=workspace.map
OBJS = $(filter-out $(IGNORE_OBJ),$(CFILES:%.c=%.o))
# replace ./ to null.
CFILES = $(subst ./,,$(SOURCES))
$(TARGET) : $(OBJS)
	@echo "making executable file..."
	$(CC) $(CXXFLAGS) -o $@ $(OBJS) $(LDFLAGS) $(LIBS)
# I think you not do anything here
# 下面的基本上不需要做任何改动了
.PHONY : everything clean 
everything : $(TARGET)
all : $(TARGET)
objs : $(OBJS)
clean :
	rm -fr *.so
	rm -fr *.o
	rm -fr *.exe
	rm -fr $(OBJS)
	rm -fr $(OBJS:%.o=%.gcda)
	rm -fr $(OBJS:%.o=%.gcno)
	rm -fr $(OBJS:%.o=%.c.gcov)
